/*
 * Copyright © 2023
 * @Author: zhangxiang
 * @Date: 2023-03-21 14:38:08
 * @LastEditors: zhangxiang
 * @LastEditTime: 2023-09-22 16:34:04
 * @Description: 调度引擎 相关接口
 * 来源：调度平台cnap-V2.1 调度引擎
 * 前缀 /cnap/vmInfo
 *
 */

import request2 from '@/utils/request2'
import request from '@/utils/request'

const PREFIX = '/cnap'

// 以下为 cnap-v2.0 相关接口

/**
 * @description: 获取云商 镜像/规格成本/硬盘 清单导出数据
 * @param {*}
 * @return {*}
 */
export function getAllExport() {
  return request2({
    url: PREFIX + '/vmInfo/v1/export/allCloudSpecs',
    method: 'get',
    headers: {
      'Content-Type': 'application/json;application/octet-stream'
    },
    responseType: 'blob'
  })
}

/**
 * @description: 获取应用场景
 * @param {*} data
 * @return {*}
 */
export function getIndicatorScene(data) {
  return request({
    url: PREFIX + '/api/indicator/info/scene',
    method: 'post',
    data
  })
}

/**
 * @description: 获取指标名称
 * @param {*} value
 * @return {*}
 */
export function getIndicatorName(data) {
  return request({
    url: PREFIX + '/api/indicator/info/indicator',
    method: 'post',
    data
  })
}

/**
 * @description: 查询指标列表
 * @param {*} value
 * @return {*}
 */
export function getIndicatorList(data) {
  return request({
    url: PREFIX + '/api/indicator/list',
    method: 'post',
    data
  })
}

/**
 * @description: 查询指标实例
 * @param {*} value
 * @return {*}
 */
export function getIndicatorCase(data) {
  return request({
    url: PREFIX + '/api/indicator/list/case',
    method: 'post',
    data
  })
}

/**
 * @description: 获取算网度量模型导出数据
 * @param {*}
 * @return {*}
 */
export function getMesaureExport() {
  return request2({
    url: PREFIX + '/api/indicator/export',
    method: 'get',
    headers: {
      'Content-Type': 'application/json;application/octet-stream'
    },
    responseType: 'blob'
  })
}

/**
 * @description: 设置代理价格折扣系数
 * @param {*} data
 * @return {*}
 */
export function saveAgencyCostDiscount(data) {
  return request({
    url: PREFIX + '/vmInfo/v1/setAccountPriceOff',
    method: 'post',
    data
  })
}

/**
 * @description: 设置代理价格模板文件
 * @param {*} data
 * @return {*}
 */
export function saveAgencyCostTemplate(data) {
  return request({
    url: PREFIX + '/vmInfo/v1/updateCostTemplate',
    method: 'post',
    data,
    headers: {
      'content-type': 'multipart/form-data'
    },
    timeout: 30 * 60000 // 30分钟超时
  })
}

/**
 * @description: 获取规格成本模板
 * @param {*} params
 * @return {*}
 */
export function getFlavorCostTemplate(params) {
  return request2({
    url: PREFIX + '/vmInfo/v1/export/flavorCostTemplate',
    method: 'get',
    params,
    headers: {
      'Content-Type': 'application/json;application/octet-stream'
    },
    responseType: 'blob'
  })
}

/**
 * @description: 查询云商
 * @param {*} params
 * @return {*}
 */
export function getCloudList(params) {
  return request({
    url: PREFIX + '/vmInfo/v1/getAllCloudType',
    method: 'get',
    params
  })
}

/**
 * @description: 查询指定云商的所有region
 * @param {*} params
 * @return {*}
 */
export function getAllRegions(params) {
  return request({
    url: PREFIX + '/vmInfo/v1/getAllRegions',
    method: 'get',
    params
  })
}

/**
 * @description: 获取指定云商的所有zone
 * @param {*} params
 * @return {*}
 */
export function getAllZones(params) {
  return request({
    url: PREFIX + '/vmInfo/v1/getAllZones',
    method: 'get',
    params
  })
}

/**
 * @description: 获取指定云商的所有可用域
 * @param {*} params
 * @return {*}
 */
export function getAllPrivateRegions(params) {
  return request({
    url: PREFIX + '/vmInfo/v1/getAllPrivateRegions',
    method: 'get',
    params
  })
}

/**
 * @description: 获取所有镜像id
 * @param {*} params
 * @return {*}
 */
export function getImageInfoForSelect(params) {
  return request({
    url: PREFIX + '/vmInfo/v1/getImageInfoForSelect',
    method: 'get',
    params
  })
}

/**
 * @description: 获取所有镜像格式
 * @param {*} params
 * @return {*}
 */
export function getImageFormatForSelect(params) {
  return request({
    url: PREFIX + '/vmInfo/v1/getAllPrivateImageFormat',
    method: 'get',
    params
  })
}

/**
 * @description: 获取所有镜像的描述
 * @param {*} params
 * @return {*}
 */
export function getImageDescribeForSelect(params) {
  return request({
    url: PREFIX + '/vmInfo/v1/getImageDescribeForSelect',
    method: 'get',
    params
  })
}

/**
 * @description: 根据条件获取所有镜像
 * @param {*} params
 * @return {*}
 */
export function getAllImageInfo(params) {
  return request({
    url: PREFIX + '/vmInfo/v1/getAllImageInfo',
    method: 'get',
    params
  })
}

/**
 * @description: 获得所有磁盘类型
 * @param {*} params
 * @return {*}
 */
export function getDiskTypeInfoForSelect(params) {
  return request({
    url: PREFIX + '/vmInfo/v1/getDiskTypeInfoForSelect',
    method: 'get',
    params
  })
}

/**
 * @description: 获得所有磁盘类型描述
 * @param {*} params
 * @return {*}
 */
export function getDiskTypeDescribeForSelect(params) {
  return request({
    url: PREFIX + '/vmInfo/v1/getDiskTypeDescribeForSelect',
    method: 'get',
    params
  })
}

/**
 * @description: 根据条件获取所有磁盘
 * @param {*} params
 * @return {*}
 */
export function getAllDiskTypeInfo(params) {
  return request({
    url: PREFIX + '/vmInfo/v1/getAllDiskTypeInfo',
    method: 'get',
    params
  })
}

/**
 * @description: 获取所有flavor id
 * @param {*} params
 * @return {*}
 */
export function getFlavorInfoForSelect(params) {
  return request({
    url: PREFIX + '/vmInfo/v1/getFlavorInfoForSelect',
    method: 'get',
    params
  })
}

/**
 * @description: 获取所有flavor描述
 * @param {*} params
 * @return {*}
 */
export function getFlavorDescribeForSelect(params) {
  return request({
    url: PREFIX + '/vmInfo/v1/getFlavorDescribeForSelect',
    method: 'get',
    params
  })
}

/**
 * @description: 获取所有flavor的价格
 * @param {*} params
 * @return {*}
 */
export function getFlavorCostForSelect(params) {
  return request({
    url: PREFIX + '/vmInfo/v1/getFlavorCostForSelect',
    method: 'get',
    params
  })
}

/**
 * @description: 获取所有flavor的相关信息
 * @param {*} params
 * @return {*}
 */
export function getAllFlavorInfo(params) {
  return request({
    url: PREFIX + '/vmInfo/v1/getAllFlavorInfo',
    method: 'get',
    params
  })
}

// 以下为 cnap-v1.5 相关接口

/**
 * @description: 获取云商规格清单数据
 * @param {*} data
 * @return {*}
 */
export function getFlavorData(params) {
  return request({
    url: PREFIX + '/vmInfo/v1/cloudSpecsList',
    method: 'get',
    params
  })
}

/**
 * @description: 获取云商价格清单数据
 * @param {*} data
 * @return {*}
 */
export function getPriceData(params) {
  return request({
    url: PREFIX + '/vmInfo/v1/vmCostList',
    method: 'get',
    params
  })
}

/**
 * @description: 获取云商规格清单导出数据
 * @param {*}
 * @return {*}
 */
export function getFlavorExport() {
  return request2({
    url: PREFIX + '/vmInfo/v1/export/cloudSpecsList',
    method: 'get',
    headers: {
      'Content-Type': 'application/json;application/octet-stream'
    },
    responseType: 'blob'
  })
}

/**
 * @description: 获取云商价格清单导出数据
 * @param {*}
 * @return {*}
 */
export function getPriceExport() {
  return request2({
    url: PREFIX + '/vmInfo/v1/export/vmCostList',
    method: 'get',
    headers: {
      'Content-Type': 'application/json;application/octet-stream'
    },
    responseType: 'blob'
  })
}
